package com.twu.biblioteca.Options;

import com.twu.biblioteca.DataBase.Item;
import com.twu.biblioteca.DataBase.ItemType;
import com.twu.biblioteca.DataBase.ListOfItems;

import java.util.Scanner;

public class ReturnBookOption extends Option{
    Scanner scanner;
    public ReturnBookOption() {
        name = "Return Book";
        scanner = new Scanner(System.in);
    }

    @Override
    public void execute(ListOfItems listOfItems) {
        System.out.println("Please type in Serial Number of the book:");

        String serialNumberString = scanner.nextLine();
        int serialNumber = Integer.parseInt(serialNumberString);
        Item item = listOfItems.getBySerialNumber(serialNumber, ItemType.Book);
        if (item != null) {
            item.returnItem();
        }
    }
}
